package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.entity.AiRecordMatchRate;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.service.IAiRecordMatchRateService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * ai录音数据的匹配率Controller
 *
 * @author ruoyi
 * @date 2025-03-18
 */
@RestController
@RequestMapping("/system/rate")
public class AiRecordMatchRateController extends BaseController
{
    @Autowired
    private IAiRecordMatchRateService aiRecordMatchRateService;

    /**
     * 查询ai录音数据的匹配率列表
     */
    @PreAuthorize("@ss.hasPermi('system:rate:list')")
    @GetMapping("/list")
    public TableDataInfo list(AiRecordMatchRate aiRecordMatchRate)
    {
        startPage();
        List<AiRecordMatchRate> list = aiRecordMatchRateService.selectAiRecordMatchRateList(aiRecordMatchRate);
        return getDataTable(list);
    }

    /**
     * 导出ai录音数据的匹配率列表
     */
    @PreAuthorize("@ss.hasPermi('system:rate:export')")
    @Log(title = "ai录音数据的匹配率", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AiRecordMatchRate aiRecordMatchRate)
    {
        List<AiRecordMatchRate> list = aiRecordMatchRateService.selectAiRecordMatchRateList(aiRecordMatchRate);
        ExcelUtil<AiRecordMatchRate> util = new ExcelUtil<AiRecordMatchRate>(AiRecordMatchRate.class);
        util.exportExcel(response, list, "ai录音数据的匹配率数据");
    }

    /**
     * 获取ai录音数据的匹配率详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:rate:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(aiRecordMatchRateService.selectAiRecordMatchRateById(id));
    }

    /**
     * 新增ai录音数据的匹配率
     */
    @PreAuthorize("@ss.hasPermi('system:rate:add')")
    @Log(title = "ai录音数据的匹配率", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AiRecordMatchRate aiRecordMatchRate)
    {
        return toAjax(aiRecordMatchRateService.insertAiRecordMatchRate(aiRecordMatchRate));
    }

    /**
     * 修改ai录音数据的匹配率
     */
    @PreAuthorize("@ss.hasPermi('system:rate:edit')")
    @Log(title = "ai录音数据的匹配率", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AiRecordMatchRate aiRecordMatchRate)
    {
        return toAjax(aiRecordMatchRateService.updateAiRecordMatchRate(aiRecordMatchRate));
    }

    /**
     * 删除ai录音数据的匹配率
     */
    @PreAuthorize("@ss.hasPermi('system:rate:remove')")
    @Log(title = "ai录音数据的匹配率", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(aiRecordMatchRateService.deleteAiRecordMatchRateByIds(ids));
    }
}
